package com.itheima.HomeWork_day14;
/*
面试题:
 */
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool05 {
    public static void main(String[] args) {
        ThreadPoolExecutor executor=new ThreadPoolExecutor(1,2,
                0L, TimeUnit.MICROSECONDS,new ArrayBlockingQueue<>(3),
                Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());

        executor.execute(new TaskThred("任务1"));
        executor.execute(new TaskThred("任务2"));
        executor.execute(new TaskThred("任务3"));
        executor.execute(new TaskThred("任务4"));
        executor.execute(new TaskThred("任务5"));
        executor.execute(new TaskThred("任务6"));
        executor.shutdown();

    }

 static class TaskThred implements Runnable{

        private String taskName;

        public TaskThred(String taskName) {
            this.taskName = taskName;
        }

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName()+taskName);
        }
    }
}
